package com.ruoyi.cms.controller.website;

import com.ruoyi.cms.domain.CmsDict;
import com.ruoyi.cms.service.ICmsDictService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author houyong
 */
@Tag(name = "CmsSiteLanguageController", description = "系统支持的语言管理 for web前端")
@RestController
@RequestMapping("cms/website/language")
public class CmsSiteLanguageController extends BaseController {


    @Autowired
    private ICmsDictService cmsDictService;


    @Operation(summary = "查询系统支持的语言列表")
    @GetMapping("/list")
    public AjaxResult list(CmsDict cmsDict) {
        cmsDict.setDictType("language");
        List<CmsDict> list = cmsDictService.selectCmsDictList(cmsDict);
        return success(list);
    }

    @Operation(summary = "查询系统支持的语言列表 for 微服务调用")
    @GetMapping("/list/for/ms/service")
    public List<CmsDict> listForMsService() {
        CmsDict cmsDict = new CmsDict();
        cmsDict.setDictType("language");
        List<CmsDict> list = cmsDictService.selectCmsDictList(cmsDict);
        return list;
    }


    //TODO 系统切换的语言 保存用户已经选择的语言

    //TODO 查询用户已经选择的语言

}
